﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/BackEnd.master" CodeFile="~/Code/Department Administrator Page.aspx.cs"
    Inherits="Department_Administrator_Page" %>


<asp:Content ID="Content1" ContentPlaceHolderID="cph_Main" runat="Server">


    Current Staffing Situation<br />
    <table style="border: 1px outset #000000; width:100%;">
        <tr>
            <td>
                <strong>Available Number
                </strong>
                <asp:Label ID="available_count_lbl" runat="server" style="font-weight: 700"></asp:Label>
                :</td>
            <td style="width: 357px; height: 23px">
                <strong>Working Number <asp:Label ID="working_count_lbl" runat="server"></asp:Label>
                </strong>:</td>
        </tr>
        <tr>
            <td style="height: 347px" valign="top">
                <asp:GridView ID="available_gv" runat="server" AllowPaging="True" 
                    AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                    DataSourceID="available_teams_ds" ForeColor="#333333" GridLines="None" 
                    Width="100%" OnDataBound="available_db" Height="100%">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="TeamName" HeaderText="TeamName" 
                            SortExpression="TeamName" />
                        <asp:BoundField DataField="Organisation_Name" HeaderText="Organisation_Name" 
                            SortExpression="Organisation_Name" />
                        <asp:BoundField DataField="Days Worked Recently" 
                            HeaderText="Days Worked Recently" SortExpression="Days Worked Recently" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <EmptyDataTemplate>
                        There are no available teams.
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
            </td>
            <td style="height: 347px" valign="top">
                <asp:GridView ID="working_gv" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" CellPadding="4" 
                    DataSourceID="working_teams_ds" ForeColor="#333333"
                    GridLines="None" OnDataBound="working_db" Height="100%">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="TeamName" HeaderText="TeamName" 
                            SortExpression="TeamName" />
                        <asp:BoundField DataField="Organisation_Name" HeaderText="Organisation_Name" 
                            SortExpression="Organisation_Name" />
                        <asp:CheckBoxField DataField="Currently working" HeaderText="Currently working" 
                            SortExpression="Currently working" />
                        <asp:BoundField DataField="Days Worked Recently" 
                            HeaderText="Days Worked Recently" SortExpression="Days Worked Recently" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <EmptyDataTemplate>
                        There are currently no teams working
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td>
                <asp:AccessDataSource ID="available_teams_ds" runat="server" 
                    DataFile="~/App_Data/Database.accdb" 
                    SelectCommand="SELECT Teams.TeamName, Organisation.Organisation_Name, Organisation.State, Teams.[Days Worked Recently] FROM (Organisation INNER JOIN Teams ON Organisation.Org_ID = Teams.[Organisation Name]) WHERE (Organisation.Organisation_Name = ?) AND (Organisation.State = ?) AND (Teams.[Currently working] = false) AND (Teams.Resting = false)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="?" QueryStringField="dept" />
                        <asp:QueryStringParameter DefaultValue="" Name="?" 
                            QueryStringField="state_id" />
                    </SelectParameters>
                </asp:AccessDataSource>
            </td>
            <td style="width: 357px">
                <asp:AccessDataSource ID="working_teams_ds" runat="server" 
                    DataFile="~/App_Data/Database.accdb" onselecting="working_teams_ds_Selecting" 
                    SelectCommand="SELECT Teams.TeamName, Teams.[Currently working], Teams.[Days Worked Recently], Organisation.Organisation_Name, Organisation.State FROM (Organisation INNER JOIN Teams ON Organisation.Org_ID = Teams.[Organisation Name]) WHERE (Teams.[Currently working] = true) AND (Organisation.Organisation_Name = ?) AND (Organisation.State = ?)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="?" QueryStringField="dept" />
                        <asp:QueryStringParameter Name="?" QueryStringField="state_id" />
                    </SelectParameters>
                </asp:AccessDataSource>
            </td>
        </tr>
        <tr>
            <td>
                Resting Number - 
                <asp:Label ID="resting_count_lbl" runat="server"></asp:Label>
                :</td>
            <td style="width: 357px; height: 23px">
            </td>
        </tr>
        <tr>
            <td valign="top">
                <asp:GridView ID="resting_gv" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" CellPadding="4" DataSourceID="resting_teams_ds" ForeColor="#333333"
                    GridLines="None" Width="424px" OnDataBound="resting_db">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:BoundField DataField="TeamName" HeaderText="TeamName" 
                            SortExpression="TeamName" />
                        <asp:BoundField DataField="Organisation Name" HeaderText="Organisation Name" 
                            SortExpression="Organisation Name" />
                        <asp:CheckBoxField DataField="Resting" HeaderText="Resting" 
                            SortExpression="Resting" />
                        <asp:BoundField DataField="Date last rested" HeaderText="Date last rested" 
                            SortExpression="Date last rested" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <EmptyDataTemplate>
                        There are currently no teams resting
                    </EmptyDataTemplate>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:AccessDataSource ID="resting_teams_ds" runat="server" 
                    DataFile="~/App_Data/Database.accdb" 
                    SelectCommand="SELECT Teams.TeamName, Teams.[Organisation Name], Teams.Resting, Teams.[Date last rested], Organisation.Organisation_Name, Organisation.State FROM (Organisation INNER JOIN Teams ON Organisation.Org_ID = Teams.[Organisation Name]) WHERE (Organisation.Organisation_Name = ?) AND (Organisation.State = ?) AND (Teams.Resting = true)">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="?" QueryStringField="dept" />
                        <asp:QueryStringParameter Name="?" QueryStringField="state_id" />
                    </SelectParameters>
                </asp:AccessDataSource>
            </td>
            <td style="width: 357px">
                &nbsp;</td>
        </tr>
    </table>

    <asp:Button ID="check_update" runat="server" onclick="check_update_Click" 
        Text="Check for Update" />
    <br />
    <br />

    <br />
    <hr />
    <br />


    Please find below your Department's current Active Jobs.
<br />
Select a job to view more information about it.<br />
<asp:GridView ID="big_Gridview" runat="server" AutoGenerateColumns="False" 
        DataSourceID="AccessDataSource1" AllowSorting="True" CellPadding="4" 
        ForeColor="#333333" GridLines="None" 
        onselectedindexchanged="big_Gridview_SelectedIndexChanged" Width="100%" 
        AllowPaging="True">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="TeamName" HeaderText="TeamName" SortExpression="TeamName" />
            <asp:BoundField DataField="Organisation_Name" HeaderText="Organisation_Name" SortExpression="Organisation_Name" />
            <asp:BoundField DataField="Incident_ID" HeaderText="Incident_ID" SortExpression="Incident_ID" />
            <asp:BoundField DataField="Job_ID" HeaderText="Job_ID" InsertVisible="False" 
                SortExpression="Job_ID" />
            <asp:CheckBoxField DataField="Job Completed?" HeaderText="Job Completed?" SortExpression="Job Completed?" />
            <asp:BoundField DataField="Date Created" HeaderText="Date Created" SortExpression="Date Created" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>


    <br />
    Please find below previously completed Jobs.<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" CellPadding="4" DataSourceID="completed_jobs_ds"
        ForeColor="#333333" GridLines="None" Width="100%">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="TeamName" HeaderText="Team" SortExpression="TeamName" />
            <asp:BoundField DataField="Organisation_Name" HeaderText="Org" SortExpression="Organisation_Name" />
            <asp:BoundField DataField="Incident_ID" HeaderText="Incident_ID" SortExpression="Incident_ID" />
            <asp:CheckBoxField DataField="Job Completed?" HeaderText="Job Completed?" SortExpression="Job Completed?" />
            <asp:BoundField DataField="Date Created" HeaderText="Date Created" SortExpression="Date Created" />
            <asp:BoundField DataField="Date Resolved" HeaderText="Date Resolved" SortExpression="Date Resolved" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    &nbsp;<asp:AccessDataSource ID="completed_jobs_ds" runat="server" DataFile="~/App_Data/Database.accdb"
        SelectCommand="SELECT DISTINCT Teams.TeamName, Organisation.Organisation_Name, Jobs.Incident_ID, Jobs.[Job Completed?], Jobs.[Date Created], Jobs.[Assigned Team], Jobs.[Date Resolved] FROM (((Incidents INNER JOIN Jobs ON Incidents.Incident_ID = Jobs.Incident_ID) INNER JOIN (Organisation INNER JOIN Teams ON Organisation.Org_ID = Teams.[Organisation Name]) ON Jobs.[Assigned Team] = Teams.Team_ID) INNER JOIN State ON Incidents.State = State.State_ID AND Organisation.State = State.State_ID) WHERE (Organisation.Organisation_Name = ?) AND (Incidents.State = ?) AND (Jobs.[Job Completed?] = true)">
        <SelectParameters>
            <asp:QueryStringParameter Name="?" QueryStringField="dept" />
            <asp:QueryStringParameter Name="?" QueryStringField="state_id" />
        </SelectParameters>
    </asp:AccessDataSource>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Database.accdb"
        SelectCommand="SELECT DISTINCT Teams.TeamName, Organisation.Organisation_Name, Jobs.Incident_ID, Jobs.[Job Completed?], Jobs.[Date Created], Jobs.[Assigned Team], Jobs.Job_ID FROM (((Incidents INNER JOIN Jobs ON Incidents.Incident_ID = Jobs.Incident_ID) INNER JOIN (Organisation INNER JOIN Teams ON Organisation.Org_ID = Teams.[Organisation Name]) ON Jobs.[Assigned Team] = Teams.Team_ID) INNER JOIN State ON Incidents.State = State.State_ID AND Organisation.State = State.State_ID) WHERE (Organisation.Organisation_Name = ?) AND (Incidents.State = ?) AND (Jobs.[Job Completed?] = false)">
        <SelectParameters>
            <asp:QueryStringParameter Name="?" QueryStringField="dept" />
            <asp:QueryStringParameter Name="?" QueryStringField="state_ID" />
        </SelectParameters>
    </asp:AccessDataSource>

    </asp:Content>

